package com.exam.bean;

import java.io.Serializable;
import java.util.Date;

import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;

/**
 *试卷实体 2012-12-27
 * 
 * @author MuLing
 * 
 */
@Entity
@Table(name = "tb_paper")
public class Paper implements Serializable {

	private static final long serialVersionUID = 1L;
	@Id
	// 指定为主键
	@GeneratedValue(strategy = GenerationType.AUTO)
	// 主键类型为自增长
	private Integer id;// 主键id

	@Column(name = "p_name", length = 100)
	private String name;// 试卷名称

	@Column(name = "p_description")
	private String description;// 试卷描述

	@Column(name = "p_allScore")
	private Integer allScore;// 试卷总分

	@Column(name = "p_duration")
	private Integer duration;// 考试时长,分钟计时

	@Temporal(TemporalType.TIMESTAMP)
	@Column(name = "p_startDateTime")
	private Date startDateTime;// 可考试开始时间

	@Temporal(TemporalType.TIMESTAMP)
	@Column(name = "p_endDateTime")
	private Date endDateTime;// 可考试结束时间

	@ManyToOne(cascade = { CascadeType.PERSIST }, fetch = FetchType.EAGER)
	@JoinColumn(name = "u_id", referencedColumnName = "id")
	private User user;// 试卷的出题者

	@ManyToOne(cascade = { CascadeType.PERSIST }, fetch = FetchType.EAGER)
	@JoinColumn(name = "pc_id", referencedColumnName = "id")
	private PaperContentType paperContentType;// 试卷的分类

	@ManyToOne(cascade = { CascadeType.PERSIST }, fetch = FetchType.EAGER)
	@JoinColumn(name = "pt_id", referencedColumnName = "id")
	private PaperSourceType paperSourceType;// 试卷的类型

	@Column(name = "p_status")
	private Integer status;// 试卷状态，待审核0、审核通过1、审核拒绝2

	public Paper() {
	}

	public Paper(Integer id, String name, String description, Integer allScore,
			Integer duration, Date startDateTime, Date endDateTime, User user,
			PaperContentType paperCategory, PaperSourceType paperType,
			Integer status) {
		super();
		this.id = id;
		this.name = name;
		this.description = description;
		this.allScore = allScore;
		this.duration = duration;
		this.startDateTime = startDateTime;
		this.endDateTime = endDateTime;
		this.user = user;
		this.setPaperContentType(paperCategory);
		this.setPaperSourceType(paperType);
		this.status = status;
	}

	/**
	 * @param id
	 *            the id to set
	 */
	public void setId(Integer id) {
		this.id = id;
	}

	/**
	 * @return the id
	 */
	public Integer getId() {
		return id;
	}

	/**
	 * @param name
	 *            the name to set
	 */
	public void setName(String name) {
		this.name = name;
	}

	/**
	 * @return the name
	 */
	public String getName() {
		return name;
	}

	/**
	 * @param allScore
	 *            the allScore to set
	 */
	public void setAllScore(Integer allScore) {
		this.allScore = allScore;
	}

	/**
	 * @return the allScore
	 */
	public Integer getAllScore() {
		return allScore;
	}

	/**
	 * @param duration
	 *            the duration to set
	 */
	public void setDuration(Integer duration) {
		this.duration = duration;
	}

	/**
	 * @return the duration
	 */
	public Integer getDuration() {
		return duration;
	}

	/**
	 * @param description
	 *            the description to set
	 */
	public void setDescription(String description) {
		this.description = description;
	}

	/**
	 * @return the description
	 */
	public String getDescription() {
		return description;
	}

	/**
	 * @param startDateTime
	 *            the startDateTime to set
	 */
	public void setStartDateTime(Date startDateTime) {
		this.startDateTime = startDateTime;
	}

	/**
	 * @return the startDateTime
	 */
	public Date getStartDateTime() {
		return startDateTime;
	}

	/**
	 * @param endDateTime
	 *            the endDateTime to set
	 */
	public void setEndDateTime(Date endDateTime) {
		this.endDateTime = endDateTime;
	}

	/**
	 * @return the endDateTime
	 */
	public Date getEndDateTime() {
		return endDateTime;
	}

	/**
	 * @param status
	 *            the status to set
	 */
	public void setStatus(Integer status) {
		this.status = status;
	}

	/**
	 * @return the status
	 */
	public Integer getStatus() {
		return status;
	}

	/**
	 * @param user
	 *            the user to set
	 */
	public void setUser(User user) {
		this.user = user;
	}

	/**
	 * @return the user
	 */
	public User getUser() {
		return user;
	}

	/**
	 * @param paperContentType the paperContentType to set
	 */
	public void setPaperContentType(PaperContentType paperContentType) {
		this.paperContentType = paperContentType;
	}

	/**
	 * @return the paperContentType
	 */
	public PaperContentType getPaperContentType() {
		return paperContentType;
	}

	/**
	 * @param paperSourceType the paperSourceType to set
	 */
	public void setPaperSourceType(PaperSourceType paperSourceType) {
		this.paperSourceType = paperSourceType;
	}

	/**
	 * @return the paperSourceType
	 */
	public PaperSourceType getPaperSourceType() {
		return paperSourceType;
	}
}
